﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using NLBS.Entity;
using System.Data;

namespace NLBS.Data
{
    public partial class NHibernateDataProvider : DbProvider
    {
        #region Category

        public override IList<Category> GetCategory()
        {
            
            return CurrentSession.CreateQuery("select c from Category as c")
                   .List<Category>();
        }

        public override Category GetCategoryByID(int catID)
        {
            return CurrentSession.Get<Category>(catID);
        }

        public override int InsertCategory(Category cat)
        {
            CurrentSession.Save(cat);
            return 1;
        }

        public override void UpdateCategory(Category cat)
        {
            CurrentSession.Update(cat);
            CurrentSession.Flush();
        }

        public override void DeleteCategory(int catID)
        {
            CurrentSession.Delete(GetCategoryByID(catID));
            CurrentSession.Flush();
        }

        public override void MoveCategory(string catIDList, int newCatID)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
